package com.csjbot.weedle_auto.util

/**
 * author : chenqi.
 * e_mail : 1650699704@163.com.
 * create_time : 8/21/17.
 */

object DataUtil {
    fun isNumeric(str: String): Boolean {
        if (str.trim { it <= ' ' }.isEmpty()) return false
        var i = str.length
        while (--i >= 0) {
            val chr = str[i].toInt()
            if (chr < 48 || chr > 57) {
                return false
            }
        }
        val a = Integer.parseInt(str)
        return a in 1..31
    }

    fun isPassToDataFromOther(scr: Int, inr: Int, pinr: Int, oa: Int): Boolean {
        return scr != 0 && inr == 31 && pinr == 5 && 15 <= oa && oa <= 45
    }

    fun isPINR(m: Int): IntArray {
        val s = IntArray(2)//左，右
        when (m) {
            1 -> {
                s[0] = 0
                s[1] = 1
            }
            2 -> {
                s[0] = 1
                s[1] = 0
            }
            3 -> {
                s[0] = 1
                s[1] = 0
            }
        }
        return s
    }

    fun isIBean(m: Int): IntArray {
        val s = IntArray(5)//右，中，左，后左，后右
        when (m) {
            1 -> {
                s[0] = 1
                s[1] = 0
                s[2] = 0
                s[3] = 0
                s[4] = 0
            }
            2 -> {
                s[0] = 0
                s[1] = 1
                s[2] = 0
                s[3] = 0
                s[4] = 0
            }
            3 -> {
                s[0] = 1
                s[1] = 1
                s[2] = 0
                s[3] = 0
                s[4] = 0
            }
            4 -> {
                s[0] = 0
                s[1] = 0
                s[2] = 1
                s[3] = 0
                s[4] = 0
            }
            5 -> {
                s[0] = 1
                s[1] = 0
                s[2] = 1
                s[3] = 0
                s[4] = 0
            }
            6 -> {
                s[0] = 0
                s[1] = 1
                s[2] = 1
                s[3] = 0
                s[4] = 0
            }
            7 -> {
                s[0] = 1
                s[1] = 1
                s[2] = 1
                s[3] = 0
                s[4] = 0
            }
            8 -> {
                s[0] = 0
                s[1] = 0
                s[2] = 0
                s[3] = 1
                s[4] = 0
            }
            9 -> {
                s[0] = 1
                s[1] = 0
                s[2] = 0
                s[3] = 1
                s[4] = 0
            }
            10 -> {
                s[0] = 0
                s[1] = 1
                s[2] = 0
                s[3] = 1
                s[4] = 0
            }
            11 -> {
                s[0] = 1
                s[1] = 1
                s[2] = 0
                s[3] = 1
                s[4] = 0
            }
            12 -> {
                s[0] = 0
                s[1] = 0
                s[2] = 1
                s[3] = 1
                s[4] = 0
            }
            13 -> {
                s[0] = 1
                s[1] = 0
                s[2] = 1
                s[3] = 1
                s[4] = 0
            }
            14 -> {
                s[0] = 0
                s[1] = 1
                s[2] = 1
                s[3] = 1
                s[4] = 0
            }
            15 -> {
                s[0] = 1
                s[1] = 1
                s[2] = 1
                s[3] = 1
                s[4] = 0
            }
            16 -> {
                s[0] = 0
                s[1] = 0
                s[2] = 0
                s[3] = 0
                s[4] = 1
            }
            17 -> {
                s[0] = 1
                s[1] = 0
                s[2] = 0
                s[3] = 0
                s[4] = 1
            }
            18 -> {
                s[0] = 0
                s[1] = 1
                s[2] = 0
                s[3] = 0
                s[4] = 1
            }
            19 -> {
                s[0] = 1
                s[1] = 1
                s[2] = 0
                s[3] = 0
                s[4] = 1
            }
            20 -> {
                s[0] = 0
                s[1] = 0
                s[2] = 1
                s[3] = 0
                s[4] = 1
            }
            21 -> {
                s[0] = 1
                s[1] = 0
                s[2] = 1
                s[3] = 0
                s[4] = 1
            }
            22 -> {
                s[0] = 0
                s[1] = 1
                s[2] = 1
                s[3] = 0
                s[4] = 1
            }
            23 -> {
                s[0] = 1
                s[1] = 1
                s[2] = 1
                s[3] = 0
                s[4] = 1
            }
            24 -> {
                s[0] = 0
                s[1] = 0
                s[2] = 0
                s[3] = 1
                s[4] = 1
            }
            25 -> {
                s[0] = 1
                s[1] = 0
                s[2] = 0
                s[3] = 1
                s[4] = 1
            }
            26 -> {
                s[0] = 0
                s[1] = 1
                s[2] = 0
                s[3] = 1
                s[4] = 1
            }
            27 -> {
                s[0] = 1
                s[1] = 1
                s[2] = 0
                s[3] = 1
                s[4] = 1
            }
            28 -> {
                s[0] = 0
                s[1] = 0
                s[2] = 1
                s[3] = 1
                s[4] = 1
            }
            29 -> {
                s[0] = 1
                s[1] = 0
                s[2] = 1
                s[3] = 1
                s[4] = 1
            }
            30 -> {
                s[0] = 0
                s[1] = 1
                s[2] = 1
                s[3] = 1
                s[4] = 1
            }
            31 -> {
                s[0] = 1
                s[1] = 1
                s[2] = 1
                s[3] = 1
                s[4] = 1
            }
        }
        return s
    }
}
